/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn;

import java.sql.DriverManager;

/**
 * <p>Project: javase - DbDemo
 * <p>Powered by webrx On 2021-12-23 10:47:58
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class DbDemo {
    public static void main(String[] args) {
        try {
            //加载数据库驱
            Class.forName("com.mysql.cj.jdbc.Driver");
            //建立数据库连接
            var c = DriverManager.getConnection("jdbc:mysql:/db?user=root");
            //
            var pst = c.prepareStatement("select version()");
            var rs = pst.executeQuery();
            rs.next();
            System.out.println(rs.getString(1));
            rs.close();
            pst.close();
            c.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
